package com.aplink.generic.google.maps.clustering.algo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.aplink.generic.google.maps.clustering.Cluster;
import com.aplink.generic.google.maps.clustering.ClusterItem;
import com.google.android.gms.maps.model.LatLng;

/**
 * A cluster whose center is determined upon creation.
 */
public class StaticCluster<T extends ClusterItem> implements Cluster<T> {
	private final LatLng mCenter;
	private final List<T> mItems = new ArrayList<T>();

	public StaticCluster(final LatLng center) {
		mCenter = center;
	}

	public boolean add(final T t) {
		return mItems.add(t);
	}

	@Override
	public Collection<T> getItems() {
		return mItems;
	}

	@Override
	public LatLng getPosition() {
		return mCenter;
	}

	@Override
	public int getSize() {
		return mItems.size();
	}

	public boolean remove(final T t) {
		return mItems.remove(t);
	}

	@Override
	public String toString() {
		return "StaticCluster{" + "mCenter=" + mCenter + ", mItems.size="
				+ mItems.size() + '}';
	}
}
